<template>
  <div class="container">
    <el-form ref="myForm" :model="ruleForm">
      <el-form-item
        v-for="item in selectList"
        :label="item.title"
        :label-width="formLabelWidth"
        :key="item.id"
        class="title"
        :prop="item.type"
      >
        <el-select v-if="item.type != 'online'" size="small" v-model="ruleForm[item.type]">
          <el-option
            v-for="(info, index) in item.children"
            :key="index"
            :label="info"
            :value="info"
          ></el-option>
        </el-select>
        <el-input
          size="small"
          v-else
          v-model="ruleForm[item.type]"
          style="width=230px"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <div class="btns">
      <el-button class="btn" type="primary" @click="showAddGoodsFrom">添加入库</el-button>
      <el-button class="btn" type="success">批量导入</el-button>
      <el-button class="btn" type="info" @click="hideAddGoodsFrom">完成入库</el-button>
    </div>
    <el-table class="box" :data="productDisassemblyOrders" border style="width: 100%">
      <el-table-column label="行号">
        <template slot-scope="scope">{{ scope.$index + 1 }}</template>
      </el-table-column>
      <el-table-column prop="status" label="商品编码"></el-table-column>
      <el-table-column prop="documentNum" label="商品名称"></el-table-column>
      <el-table-column prop="createDate" label="模具号"></el-table-column>
      <el-table-column prop="headquartersName" label="电商款号"></el-table-column>
      <el-table-column prop="category" label="款号"></el-table-column>
      <el-table-column prop="count" label="分类1"></el-table-column>
      <el-table-column prop="totalWeight" label="证书1"></el-table-column>
      <el-table-column prop="totalPrice" label="成色"></el-table-column>
      <el-table-column prop="LabelTotalPrice" label="重量"></el-table-column>
      <el-table-column prop="createPerson" label="单件重"></el-table-column>
      <el-table-column prop="approver" label="数量"></el-table-column>
      <el-table-column prop="approvalDate" label="手寸"></el-table-column>
      <el-table-column prop="approvalDate" label="料价"></el-table-column>
      <el-table-column prop="approvalDate" label="销售工费"></el-table-column>
      <el-table-column prop="approvalDate" label="附加费"></el-table-column>
      <el-table-column prop="approvalDate" label="系列名称"></el-table-column>
      <el-table-column prop="approvalDate" label="备注"></el-table-column>
      <el-table-column prop="approvalDate" label="品牌"></el-table-column>
      <el-table-column prop="approvalDate" label="价格类型"></el-table-column>
      <el-table-column prop="approvalDate" label="标签单价"></el-table-column>
      <el-table-column prop="approvalDate" label="成本计价"></el-table-column>
      <el-table-column prop="approvalDate" label="销售计价"></el-table-column>
      <el-table-column prop="approvalDate" label="销售工费计价"></el-table-column>
      <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button type="text" @click="handleClick(scope)" size="small">查看(编辑)</el-button>
          <el-button type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <PageComponents />
    <div class="wrapper" v-show="isshowAddGoodsFrom">
      <div class="wrapper-content">
        <AddGoodsFrom
          :isshowAddGoodsFrom="isshowAddGoodsFrom"
          @closeAddForm="isshowAddGoodsFrom = false"
        />
      </div>
    </div>
  </div>
</template>

<script>
import AddGoodsFrom from "@/components/inbounchComponents/AddGoodsFrom.vue";
import PageComponents from "@/components/PageComponents.vue";
export default {
  name: "AddGoodsInbounch",
  props: ["formLabelWidth", "total", "curPage"],
  components: {
    AddGoodsFrom,
    PageComponents
  },
  data() {
    return {
      listInfo: {},
      isshowAddGoodsFrom: false,
      ruleForm: {
        category: "",
        source: "",
        inbounch: "",
        createTime: "",
        provider: "",
        online: "",
        tagName: "",
        DNnumber: ""
      },
      productDisassemblyOrders: [
        {
          goodsId: 1, // id
          status: 1, // 状态（0：已驳回；1：已通过；2：待审核）
          documentNum: 1, // 单据编号
          createDate: 1, // 创单时间
          headquartersName: 1, // 总部名称
          category: 1, // 商品类型
          count: 1, // 数量
          totalWeight: 1, // 总重量
          totalPrice: 1, // 总成本
          LabelTotalPrice: 1, // 标签总价
          createPerson: 1, // 创单人
          approver: 1, // 审批人
          approvalDate: 1 // 审批日期
        }
      ],
      selectList: [
        {
          id: 1,
          title: "商品类型",
          children: ["素金类", "镶嵌类", "其他类"],
          type: "category"
        },
        {
          id: 2,
          title: "来源",
          children: ["采购", "代销", "联销", "加工", "其他"],
          type: "source"
        },
        {
          id: 3,
          title: "入库门店",
          children: ["北京总部", "上海分公司"],
          type: "inbounch"
        },
        {
          id: 4,
          title: "创单时间",
          children: "new Date()",
          type: "createTime"
        },
        {
          id: 5,
          title: "供应商",
          children: ["供应商1", "供应商2"],
          type: "provider"
        },
        {
          id: 6,
          title: "订单号",
          children: "(Math.random * 10000).toFixed(5)",
          type: "online"
        },
        {
          id: 7,
          title: "柜台/类库名称",
          children: ["黄金类", "珠宝类"],
          type: "tagName"
        },
        {
          id: 8,
          title: "单据编号",
          children: "3243241",
          type: "DNnumber"
        }
      ]
    };
  },
  created() {},
  mounted() {
    this.$bus.$on("postInfo", () => {
      this.selectList.forEach(item => {
        this.listInfo[item.type] = this.ruleForm[item.type];
      });
      this.$refs.myForm.resetFields();
      console.log(this.listInfo);
    });
  },
  methods: {
    showAddGoodsFrom() {
      this.isshowAddGoodsFrom = true;
    },
    hideAddGoodsFrom() {
      this.isshowAddGoodsFrom = false;
    }
  }
};
</script>

<style scoped lang="scss">
.container {
  .el-form {
    width: 1040px;
    float: left;
  }
  .btns {
    height: 100px;
    line-height: 100px;
    float: right;
    margin-right: 100px;
    .btn {
      width: 80px;
      height: 80px;
      margin-left: 20px;
      padding: 0;
    }
  }
  .wrapper {
    position: relative;
    top: -128px;
    background: #fff;
    height: 400px;
    width: 100%;
    z-index: 666;
    .wrapper-content {
      position: absolute;
      width: 100%;
      height: 100%;
      overflow-y: scroll;
      border: 1px solid #ccc;
    }
  }
}
</style>